﻿using Common.Tools.Logger;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Exceptionless;
using System.Net;

namespace Common.Tools.Filter
{
    public class ExceptionFilter : IExceptionFilter
    {
        public void OnException(ExceptionContext context)
        {
            context.Exception.ToExceptionless().Submit();

            context.Result = new ContentResult()
            {
                StatusCode = (int)HttpStatusCode.InternalServerError,
                Content = context.Exception.Message
            };
        }
    }
}
